function isEmpty(field) {
    return (field.value == "");
}

function textLeaveMessage(component, intialMessage) {
    if(component.style.color == "gray" && component.value == intialMessage) {
        component.value = "";
    }

    component.style.color = "black";
}

function textAreaLeaveMessage(component, intialMessage) {
    if(component.style.color == "gray" && component.innerHTML == intialMessage) {
        component.innerHTML = "";
    }

    component.style.color = "black";
}

function hide(id) {
    var loginError = document.getElementById(id);
    loginError.style.visibility = "hidden";
}

function showError(id, message) {
    var error = document.getElementById(id);
    hide(id);
    error.innerHTML = message;
    error.style.color = "red";
    error.style.visibility = "visible";
}

function legalChar(ch) {
    return ((ch <= 'z' && ch >= 'a') ||
            (ch <= 'Z' && ch >= 'A') ||
             ch == '_' || ch == '.');
}

function invalidEmail(mail) {
    var expression = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
    if (!expression.test(mail))
    {
        return true;
    }

    return false;
}